/**
 * 
 */
package arisufascion.com.activity;

import android.os.AsyncTask;
import android.os.Bundle;
import android.os.SystemClock;
import android.widget.ProgressBar;
import arisufascion.com.AbstractActivity;
import arisufascion.com.R;

/**
 * @author Kelvin
 * 
 */
public class ActivitySplashScreen extends AbstractActivity {

	private ProgressBar progressBar;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.activity_splash);

		progressBar = (ProgressBar) findViewById(R.id.progressBar1);

		new ShowCustomProgressBarAsyncTask().execute(); 
		
	}

	public class ShowCustomProgressBarAsyncTask extends
			AsyncTask<Void, Integer, Void> {

		int myProgress;

		@Override
		protected void onPreExecute() {
			myProgress = 0;
			progressBar.setSecondaryProgress(0);
		}

		@Override
		protected Void doInBackground(Void... params) {
			while (myProgress < 100) {
				myProgress++;
				publishProgress(myProgress);
				SystemClock.sleep(100);
			}
			return null;
		}

		@Override
		protected void onProgressUpdate(Integer... values) {
			progressBar.setProgress(values[0]);
			progressBar.setSecondaryProgress(values[0] + 5);
		}

		/* (non-Javadoc)
		 * @see android.os.AsyncTask#onPostExecute(java.lang.Object)
		 */
		@Override
		protected void onPostExecute(Void result) {
			// TODO Auto-generated method stub
			super.onPostExecute(result);
			gotoActivity(self, TabsActivity.class);
			self.finish();
			
			
		}
		
	}

}
